package com.lecture.springlecture.taks;

import com.lecture.java8.date.DateUtil;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class TestTask {

    @Scheduled(cron = "0 0/1 * * * ?")
    @SchedulerLock(name = "scheduledTaskName", lockAtMostFor = "1m", lockAtLeastFor = "1m")
    public void scheduledTask() {
        // Task implementation
        System.out.println("Executing scheduled task" + DateUtil.formatDateTime(new Date()));
    }
}
